package com.speedydial;

import com.speedydial.model.SMSContact;

import android.app.ListActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ListView;

/**
 * Demo de como listar diferentes items usando el Adapter view
 * @author mario
 *
 */
public class InitialListActivity extends ListActivity {
	
	

	@Override
	protected void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		
		setListAdapter(new ContactAdapter(
				new SMSContact("Joan","897788","no llego", 8, "Rapid"),
				new SMSContact("Mario","897788","no llego", 8, "Rapid"),
				new SMSContact("Ana","897788","no llego", 8, "Rapid"),
				new SMSContact("Montse","897788","no llego", 8, "Rapid")
		));
//		setContentView(R.layout.)
	}

	@Override
	protected void onListItemClick(ListView parent, View v, int position, long id) {
//		super.onListItemClick(parent, v, position, id);
		
		// get adpter
		ContactAdapter adptr = (ContactAdapter)  parent.getAdapter();
		
		SMSContact contact = (SMSContact) adptr.getItem(position);
		contact.msgCount++;
		
		adptr.notifyDataSetInvalidated();
		
	}
	
	

}
